x86 hvm: Refuse to perform __hvm_copy() work in atomic context.
authorKeir Fraser <keir@xen.org>
Thu, 18 Nov 2010 12:28:31 +0000 (12:28 +0000)
committerKeir Fraser <keir@xen.org>
Thu, 18 Nov 2010 12:28:31 +0000 (12:28 +0000)
Soon we will properly handle paged out memory in this function by
sleeping in hypervisor context. This will require that all callers can
sleep.

If this check is too strong, we can reduce it to only applying to
guests with paging enabled (which also currently implies only guests
using Intel EPT). However my brief testing seems to indicate it works
okay.

Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/hvm/hvm.c

index ccf0d88b9e753cd076268869396444a954df3d3b..bede0ae658d2679d2e4475088cd632518669f476 100644 (file)
@@ -1905,6 +1905,13 @@ static enum hvm_copy_result __hvm_copy(
     char *p;
     int count, todo = size;
 
+    /*
+     * If the required guest memory is paged out, this function may sleep.
+     * Hence we bail immediately if called from atomic context.
+     */
+    if ( in_atomic() )
+        return HVMCOPY_unhandleable;
+
     while ( todo > 0 )
     {
         count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo);